import java.io.Serializable;


@SuppressWarnings("serial")
public class BoardCell implements Serializable {
	private String content;
	private transient Rights rights = new Rights();
	
	public BoardCell(String letter)
	{
		this.content = letter.toUpperCase();
	}
	
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		if (content.length() != 1) return;
		this.content = content;
	}
	
	public void enableStart()
	{
		rights.setStart(true);
	}
	
	public void enableEnd()
	{
		rights.setEnd(true);
	}
	
	public void enableInner()
	{
		rights.setInner(true);
	}
	
	public void disableStart()
	{
		rights.setStart(false);
	}
	
	public void disableEnd()
	{
		rights.setEnd(false);
	}
	
	public void disableInner()
	{
		rights.setInner(false);
	}
	
	public boolean isStart()
	{
		return rights.isStart();
	}
	
	public boolean isEnd()
	{
		return rights.isEnd();
	}
	
	public boolean isInner()
	{
		return rights.isInner();
	}
	
	public void disable()
	{
		rights.disableAll();
	}
	
	public boolean isDisabled()
	{
		return rights.isDisabled();
	}
	
	public boolean isFullyEnabled()
	{
		return rights.isStart() && rights.isEnd() && rights.isInner();
	}
	
	public void setDirection(Direction d)
	{
		rights.setD(d);
	}
	public Direction getDirection()
	{
		return rights.getD();
	}
	
	private class Rights
	{
		
		private boolean isStart = true;
		private boolean isEnd = true;
		private boolean isInner = true;
		Direction d = Direction.BOTH;
		
		public Direction getD() {
			return d;
		}
		public void setD(Direction d) {
			this.d = d;
		}
		public boolean isStart() {
			return isStart;
		}
		public void setStart(boolean isStart) {
			this.isStart = isStart;
		}
		public boolean isEnd() {
			return isEnd;
		}
		public void setEnd(boolean isEnd) {
			this.isEnd = isEnd;
		}
		public boolean isInner() {
			return isInner;
		}
		public void setInner(boolean isInner) {
			this.isInner = isInner;
		}
		public void disableAll()
		{
			this.isStart = false;
			this.isInner = false;
			this.isEnd = false;
		}
		public boolean isDisabled()
		{
			return this.isStart == false && this.isInner == false && this.isEnd == false;
		}
	}
}
